<template>
    <div>
        <el-dialog v-model="ViewdialogVisible" width="80%" align-center destroy-on-close draggable>
            <template #header="{ close }">
                <div class="dialog-header flex justify-between items-center">
                    <div>讲座查看</div>
                    <el-icon class="el-icon--left cursor-pointer" @click="close">
                        <CircleCloseFilled color="#fff" />
                    </el-icon>
                </div>
            </template>
            <div>
                <!-- 基本信息 -->
                <div class="bg-white mt-[10px]">
                    <div class="px-[5px]  text-right" v-if="procInsId != null">
                        <el-link type="primary" @click="checkHistoryModalVisible = true">审核记录</el-link>
                    </div>
                    <BaseHead>基本信息</BaseHead>
                    <div class="p-[10px]">
                        <el-descriptions title="" :column="2" border label-width="140">
                            <el-descriptions-item label-class-name="gdlable" label="讲座名称">{{
            ruleForm.name
        }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="讲座类型">{{
                formatlectureTypeId(ruleForm.lectureTypeId)
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="讲座日期">{{
                dateFormatter3(ruleForm.lectureDate)
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="讲座级别">{{
                formatlectureLevelId(ruleForm.lectureLevelId)
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="主讲人">{{
                ruleForm.lecturer
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="所属单位">{{
                formatunitId(ruleForm.unitId)
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="观点综述">{{
                ruleForm.intro
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="会议相关文档">
                                <div v-for="item in ruleForm.fileList" :key="item.id">{{ item.fileName
                                    }}<el-link type="primary" style="margin-left: 8px;"
                                        @click="downloadMet(item.id)">下载</el-link>
                                </div>
                            </el-descriptions-item>
                        </el-descriptions>
                    </div>
                </div>
                <!-- 详细信息 -->
                <div class="bg-white mt-[10px]">
                    <BaseHead>详细信息</BaseHead>
                    <div class="p-[10px]">
                        <el-descriptions title="" :column="2" border label-width="140">
                            <el-descriptions-item label-class-name="gdlable" label="主讲人单位">{{
            ruleForm.lecturerUnit
        }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="主讲人职务">{{
                ruleForm.lecturerDuty
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="主讲人职称">{{
                ruleForm.lecturerTitle
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="主持人">{{
                ruleForm.compere
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="嘉宾">{{
                ruleForm.commend
            }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="讲座对象">{{
                                ruleForm.lectureListener
                                }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="参加讲座人数">{{
                                ruleForm.listenerNumber
                                }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="讲座地点">{{
                                ruleForm.address
                                }}</el-descriptions-item>
                            <el-descriptions-item label-class-name="gdlable" label="主讲人学术简历">{{
                                ruleForm.lecturerInfo
                                }}</el-descriptions-item>
                        </el-descriptions>
                    </div>
                </div>
            </div>
        </el-dialog>
    </div>
    <CheckHistoryModal v-model="checkHistoryModalVisible" :procInsId="procInsId" :checker="checker"
        :checkDate="checkDate" />
</template>
<script setup>
import BaseHead from "@/views/project/components/BaseHead.vue";
import CheckHistoryModal from "@/views/project/components/CheckHistoryModal.vue";

const ViewdialogVisible = defineModel();
const props = defineProps({
    jzlxList: Array,
    jzjbList: Array,
    zcgsdwList: Array,
})

const checkHistoryModalVisible = ref(false);
const procInsId = ref(null); //流程实例id
const checker = ref("");
const checkDate = ref("");

const ruleForm = reactive({
    name: '',
    lectureTypeId: '',
    lectureDate: '',
    lectureLevelId: '',
    lecturer: '',
    unitId: '',
    intro: '',
    lecturerUnit: '',
    lecturerTitle: '',
    lecturerDuty: '',
    compere: '',
    commend: '',
    lectureListener: '',
    listenerNumber: null,
    address: '',
    lecturerInfo: '',
});
const tableData = reactive([
]);

const formatlectureTypeId = (cellValue) => {
    if (props.jzlxList.length && cellValue) {
        return props.jzlxList.find(item => item.code == cellValue).name
    } else {
        return ''
    }


}
const formatlectureLevelId = (cellValue) => {
    if (props.jzjbList.length && cellValue) {
        return props.jzjbList.find(item => item.code == cellValue).name
    } else {
        return ''
    }


}

const formatunitId = (cellValue) => {
    if (props.zcgsdwList.length && cellValue) {
        return props.zcgsdwList.find(item => item.codeColumn == cellValue).valueColumn
    } else {
        return ''
    }


}


const getRuleForm = (i) => {
    if (i.honorAuthorVOs && i.honorAuthorVOs.length > 0) {
        tableData.length = 0; // 清空数组
        tableData.push(...i.honorAuthorVOs); // 添加新元素

    }
    for (const key in i) {
        ruleForm[key] = i[key];
    }
    procInsId.value = ruleForm.processInstanceId;
    checker.value = ruleForm.checker;
    checkDate.value = ruleForm.checkdate;
}
const { proxy } = getCurrentInstance();
const downloadMet = (i) => {
    proxy.$download.common(i)
}
defineExpose({
    getRuleForm
})
</script>
<style lang="scss">
.gdlable {
    width: 140px;
}
</style>
<style scoped lang="scss">
@import url("@/views/achievement/index.scss");

:deep(.el-select--default) {


    .el-select__wrapper.is-disabled {
        background-color: #fff;
        box-shadow: 0 0 0 0px var(--el-select-disabled-border) inset;
        color: #606266;
        cursor: not-allowed;

        .el-select__selected-item {
            color: #606266;
        }
    }

    .el-select__suffix {
        display: none;
    }
}
</style>
